//
//  DetailDock.m
//  小团购
//
//  Created by 樊荣海 on 15/2/4.
//  Copyright (c) 2015年 樊荣海. All rights reserved.
//

#import "DetailDock.h"

@implementation DetailDock {

    DetailDockBtn *_currentBtn;
    
}

+ (instancetype)detailDock {
    
    return [[NSBundle mainBundle] loadNibNamed:@"DetailDock" owner:nil options:nil][0];
}

- (void)awakeFromNib {
    
    [self btnClick:_infoBtn];
}


- (IBAction)btnClick:(DetailDockBtn *)sender {
    
    NSLog(@"from:%d, to:%d",_currentBtn.tag ,sender.tag );
    [_delegate detailDock:self selectedFrom:_currentBtn.tag to:sender.tag];
//    if ([_delegate respondsToSelector:@selector(detailDock:selectedFrom:to:)]) {
//        
//        NSLog(@"from:%d, to:%d",_currentBtn.tag ,sender.tag );
//        [_delegate detailDock:self selectedFrom:_currentBtn.tag to:sender.tag];
//    }

    
    sender.enabled = NO;
    _currentBtn.enabled = YES;
    _currentBtn = sender;
    
    if (sender == _infoBtn) {// 第一个按钮
        [self insertSubview:_detailBtn atIndex:0];
    } else if (sender == _detailBtn) {
        [self insertSubview:_infoBtn atIndex:0];
    }
    
    [self bringSubviewToFront:_currentBtn];
    
    
    
}




- (void)setFrame:(CGRect)frame {

    frame.size = self.frame.size;
    [super setFrame:frame];
}


@end


@implementation DetailDockBtn

- (void)setHighlighted:(BOOL)highlighted {}

@end


